home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / check_item.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-07-26  |  1.4 KB  |  59 lines

  1. /*
  2.    check_item: given a value and a change format structure, make sure
  3.    that the value is in range.
  4.  
  5.    Basically, this routine is a large switch statement on the type of
  6.    change that grabs the necessary info, and checks to see if the item
  7.    is worth mentioning.
  8.  
  9.    Note that what we print out depends on whether or not something else
  10.    has been found wrong on this line.
  11.  
  12.    Kenneth Ingham
  13.  
  14.    Copyright (C) 1987 The University of New Mexico
  15. */
  16.  
  17. #include "defs.h"
  18. #include "y.tab.h"
  19.  
  20. check_item(cf, value, cmd, line, prev_val)
  21. char *value, *cmd, *line;
  22. struct change_fmt_st *cf;
  23. struct everything *prev_val;
  24. {
  25.     extern int line_ok, cmd_ok;
  26.  
  27.     switch(cf->fmt.type) {
  28.         case PERCENT:
  29.             if (prev_val == NULL) /* nothing to compare with */
  30.                 return;
  31.             pct_check(value, prev_val, cf->fmt.fmt.percent,
  32.                 cmd, cf->name, line);
  33.             break;
  34.         case ABSOLUTE:
  35.             if (prev_val == NULL) /* nothing to compare with */
  36.                 return;
  37.             abs_check(value, prev_val, cf->fmt.fmt.abs_amount,
  38.                 cmd, cf->name, line);
  39.             break;
  40.         case MAX_MIN:
  41.             maxmin_check(value, cf->fmt.fmt.max_min.max,
  42.                 cf->fmt.fmt.max_min.min, cmd, cf->name, line);
  43.             break;
  44.         case STRING:
  45.             str_check(value, cf->fmt.fmt.str_value, cmd,
  46.                 cf->name, line);
  47.             break;
  48.         case ANY:
  49.             if (prev_val == NULL) /* nothing to compare with */
  50.                 return;
  51.             any_check(value, prev_val, cmd, cf->name, line);
  52.             break;
  53.         default:
  54.             printf("check_item: impossible condition\n");
  55.             break;
  56.     }
  57.     cmd_ok = line_ok;
  58. }
  59.